<template>
  <el-container>
    <el-header>
      <el-menu class="el-menu-demo" mode="horizontal" background-color="#545c64" text-color="#fff"
        active-text-color="#545c64">
        <el-menu-item index="1">选课中心</el-menu-item>
        <el-menu-item index="2">讲师团队</el-menu-item>
        <el-menu-item index="3">意见反馈</el-menu-item>
        <el-menu-item index="4">
          <el-dropdown @command="handleCommand">
            <span class="el-dropdown-link">
              <el-avatar size="small" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png">
              </el-avatar>
              {{nickname}}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-plus" command="info">个人中心</el-dropdown-item>
              <el-dropdown-item icon="el-icon-circle-plus" command="pwd">修改密码</el-dropdown-item>
              <el-dropdown-item icon="el-icon-circle-plus-outline" command="quit">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-menu-item>
      </el-menu>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu :router="true" default-active="/clist" class="el-menu-vertical-demo" background-color="#545c64"
          text-color="#fff" active-text-color="#ffd04b">
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>课程管理</span>
            </template>
            <el-menu-item index="/clist">课程列表</el-menu-item>
          </el-submenu>
          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title">流程管理</span>
          </el-menu-item>
          <el-menu-item index="3">
            <i class="el-icon-document"></i>
            <span slot="title">人员管理</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">系统设置</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
  export default {
    data() {
      return {
        nickname: ''
      }
    },
    mounted() {
      const rs = JSON.parse(localStorage.getItem("rs"));
      this.nickname = rs.nickname;
    },
    methods: {
      handleCommand(command) {
        if (command == 'quit') {
          let rs = localStorage.getItem("rs");
          rs = JSON.parse(rs);
          rs.apiKey = '';
          this.$router.push('/login');
        }
      }
    }
  }
</script>

<style scoped>
  .el-dropdown {
    color: orange;
  }

  .el-menu-demo {
    display: flex;
    justify-content: right;
  }

  .el-container {
    height: 100%;
  }

  .el-header {
    background-color: #545c64;
  }

  .el-aside {
    background-color: #545c64;
  }

  .el-main {
    /* background-color: green; */
  }

  .el-menu {
    border-right: solid 0px #e6e6e6;
  }
</style>
